package org.jcommon.com.util.collections;

import java.util.Collection;
import java.util.Vector;
/**
 * 
 * @author LeoLee<leo.li@protel.com.hk>
 *
 */
public class CollectionStore {
	private Collection<Object> store;
	
	public CollectionStore(){
		store = new Vector<Object>();
	}
	
	public CollectionStore(Collection<Object> store){
		this.store = store;
	}
	
	protected boolean addOne(Object key){
		synchronized(store){
			if(!store.contains(key)){
				store.add(key);
				return true;
			}
		}
		return false;
	}
	
	protected boolean hasKey(Object key){
		return store.contains(key);
	}
	
	protected boolean removeOne(Object key){
		synchronized(store){
			if(store.contains(key)){
				store.remove(key);
				return true;
			}
		}
		return false;
	}
	
	protected Collection<Object> getAll(){
		return store;
	}
	
	protected void resetAll(Collection<Object> store){
		this.store = store;
	}
	
	protected void clear() {
		// TODO Auto-generated method stub
		store.clear();
	}
}
